<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>网络监听</title>
</head>
<body>
  <h2> JSPang.com  断网提醒测试 </h2>
</body>
<script>
  window.addEventListener('online',function(){
    alert('官人，我来了，我们继续哦！')
  })

  window.addEventListener('offline',function(){
    alert('小女子先行离开一会，请稍等！')
  })
</script>
</html>